<template>
  <div class="left-menu">
    <el-row class="tac" style="height: 100%">
      <el-col :span="12" style="height: 100%">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#545c64"
          text-color="#fff"
          style="height: 100%"
          router
          active-text-color="#ffd04b"
        >
          <div class="menu-item" v-for="item in menuList" :key="item.menuId">
            <el-submenu v-if="item.level == 0" :index="'/'+item.url">
              <template slot="title">
                <i :class="item.icon"></i>
                <span>{{ item.title }}</span>
              </template>
              <el-menu-item 
                v-for="menu_item in getMenuNode(item.menuId)"
                :key="menu_item.menuId"
                :index="'/'+item.url+'/'+menu_item.url"
              >
                <template slot="title">
                  <i :class="menu_item.icon"></i>
                  <span>{{ menu_item.title }}</span>
                </template>
              </el-menu-item>
            </el-submenu>
          </div>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import { info } from "@/api/info.js";
export default {
  data() {
    return {
      menuList: []
    };
  },
  created() {
    
  },
  	watch:{
		'$store.getters.menus'(newVal,oldVal){
			this.menuList = newVal
		
		}
	},
  methods: {
    // handleOpen(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    // handleClose(key, keyPath) {
    //   console.log(key, keyPath);
    // },
    getMenuNode(menuId) {
      return this.menuList.filter((item) =>{ 
        return item.parentId === menuId
        });
    },
  },
};
</script>

<style>
.left-menu {
  height: 100%;
  width: 180px;
}
.el-col-12 {
  width: 100%;
}
.el-menu-item{
  min-width: 179px!important;
}
</style>